<?php

declare(strict_types=1);
/**
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2023/5/25.
 */

namespace App\Exceptions;

class ServiceException extends \RuntimeException
{
    public function __construct($data)
    {
        if (\is_array($data)) {
            parent::__construct($data['message'], $data['code'] ?? 10000);
        } else {
            if (\in_array($data, CommonExceptionConstants::getValues()->toArray(), true)) {
                parent::__construct(CommonExceptionConstants::getDescription($data), $data);
            } else {
                parent::__construct($data, 1000);
            }
        }
    }
}
